using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.IO;
using System.Collections;

using FluorineFx;
using FluorineFx.Net;
using FluorineFx.Messaging.Api;
using FluorineFx.Messaging.Api.Service;
using FluorineFx.AMF3;
using System.Net;
using System.Text.RegularExpressions;

namespace GameHacker.Mail
{
    public partial class MailListForm : DevExpress.XtraEditors.XtraForm
    {
        private string m_SesstionCookie;

        public MailListForm(string sessionCookie)
        {
            m_SesstionCookie = sessionCookie;
            InitializeComponent();
            LoadMailList();
        }

        private void LoadMailList()
        {
            

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://skype.space.ccnec.com/GameShow/mail.list.php");
            request.Method = @"GET";
            request.UserAgent = @"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)";
            request.Accept = @"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            request.Headers[HttpRequestHeader.AcceptCharset] = @"ISO-8859-1,utf-8;q=0.7,*;q=0.7";
            request.Headers[HttpRequestHeader.AcceptEncoding] = @"gzip,deflate";
            request.Headers[HttpRequestHeader.AcceptLanguage] = @"en-us,en;q=0.5";
            request.KeepAlive = true;
            request.Headers[HttpRequestHeader.Cookie] = m_SesstionCookie;

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream responseStream = response.GetResponseStream();
            StringBuilder responseContent = new StringBuilder();
            byte[] buffer = new byte[256];
            int readedCount = 0;
            do
            {
                readedCount = responseStream.Read(buffer, 0, buffer.Length);
                responseContent.Append(Encoding.ASCII.GetString(buffer, 0, readedCount));
            } while (readedCount > 0);

            Regex pattern = new Regex(@"<table cellpadding=""0"" align=""center"" cellspacing=""0"" border=""0"" background=""images/dw.gif"" width=""860"" class=""colora"">(.*)</table>");
            Match rexMatch = pattern.Match(responseContent.ToString());
            if (rexMatch.Success && rexMatch.Groups.Count > 0)
            {
                string content = rexMatch.Groups[1].Value;
            }
        }

        
    }

    
}